# !/usr/bin/env python
# -*- coding: utf8 -*-
# title       :
# description :
# author      :'ShenMeng'

import pymel.core as pmel


class Validation():
    name = u'LockAttr | 属性锁定检查'
    description = u"""检查物体的属性是否有锁定"""
    dataDict = dict()

    def execute(self):
        self.dataDict = {}
        objList = pmel.ls(tr=1)
        meshList = pmel.ls(type='mesh')
        if objList:
            for obj in objList:
                attrList = pmel.listAttr(obj, l=1)
                if attrList:
                    self.dataDict[obj.name()] = attrList
        if meshList:
            for mesh in meshList:
                attrList = pmel.listAttr(mesh, l=1)
                if attrList:
                    self.dataDict[mesh.name()] = attrList
        return self.dataDict

    def correct(self):
        if self.dataDict:
            for k, attrList in self.dataDict.items():
                for attr in attrList:
                    attr_node = pmel.PyNode(k + '.' + attr)
                    attr_node.setLocked(0)

    def search(self, obj):
        pmel.select(obj)
